package com.yqb.study.common.warpper.log;

import java.util.HashMap;

/**
 * 包装字段为中文,从字典Dict中转义数字 
 * 日志格式如下: 
 * name = vinnie 
 * role = 2 
 * sex = 0 
 * city = 上海
 */
public abstract class BaseLogWarpperMap {

	protected HashMap<String, String> fieldWarpper = new HashMap<>();
	protected HashMap<String, String> fieldNumWarpper = new HashMap<>();

	public BaseLogWarpperMap() {
		putFieldWarpper("id", "主键id");
		// 分页参数limit、offset、sort、order
		putFieldWarpper("limit", "页记录数");
		putFieldWarpper("offset", "偏移量");
		putFieldWarpper("sort", "排序字段");
		putFieldWarpper("order", "排序方向");
		
		initFieldWarpper();
		initFieldNumWarpper();
	}

	/**
	 * 初始化字段英文名称和中文名称的对应(例如:role和角色)
	 */
	public abstract void initFieldWarpper();

	/**
	 * 初始化需要被包装的字段和字典中base名称对应(例如:sex = 0中0需要被转义,保存sex和性别)
	 */
	protected abstract void initFieldNumWarpper();

	public String getFieldWarpper(String key) {
		return this.fieldWarpper.get(key);
	}

	public void putFieldWarpper(String key, String value) {
		this.fieldWarpper.put(key, value);
	}

	public String getFieldNumWarpper(String key) {
		return this.fieldNumWarpper.get(key);
	}

	public void putFieldNumWarpper(String key, String methodName) {
		this.fieldNumWarpper.put(key, methodName);
	}
}
